package ic.symbols;

import ic.ast.decl.DeclField;
import ic.ast.decl.Type;
import ic.types.TypeTable;

/**
 * Created with IntelliJ IDEA.
 * User: Matan
 * Date: 12/10/13
 * Time: 11:26 AM
 */
public class FieldSymbol extends Symbol {

    private DeclField field;
    private Type type;

    public FieldSymbol(DeclField declField) throws Exception {
        super(declField.getName(), SymbolType.FIELD, declField.getLine());
        this.field = declField;
        this.type = TypeTable.getType(declField.getType());
    }

    public DeclField getField() {
        return field;
    }

    public Type getType() {
        return this.type;
    }

    public String toString() {
        StringBuilder str = new StringBuilder();
        str.append("Field:  ");
        str.append(getID());
        str.append(" : ");
        str.append(getType());
        return str.toString();
    }
}

